#include"../../server/Rpc_Server.hpp"


void Add(const Json::Value &req, Json::Value &rsp) {
   
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = num1 + num2;

    sleep(1);
    LOG(LogLevel::DEBUG)<<"num1 :" <<num1<<"  num2 : "<<num2<<"  rsp:"<<rsp;
}

int main()
{
    xu::server::RpcRouter::Ptr rr = std::make_shared<xu::server::RpcRouter>();
    xu::server::SDescribeFactory::Ptr sd = std::make_shared<xu::server::SDescribeFactory>();
    sd->SetMethod("Add");
    sd->SetParameter("num1",xu::server::VType::INTEGRAL);
    sd->SetParameter("num2",xu::server::VType::INTEGRAL);
    sd->SetCallback(Add);
    sd->SetRestype(xu::server::VType::INTEGRAL);

    xu::server::RpcServer rs(xu::Address("127.0.0.1",9191),true,xu::Address("127.0.0.1",9999));
    rs.registerMethod(sd->Build());
    rs.Start();
    
    return 0;
}
